home *** CD-ROM | disk | FTP | other *** search
/ Team Palmtops 7 / Palmtops_numero07.iso / WinCE / SDKWindowsCE / HandHeldPCPro30 / sdk.exe / Jupiter SDK / data1.cab / MFC / src / auxdata.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1999-02-19  |  4.2 KB  |  148 lines

  1. // This is a part of the Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992-1998 Microsoft Corporation
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Foundation Classes Reference and related
  7. // electronic documentation provided with the library.
  8. // See these sources for detailed information regarding the
  9. // Microsoft Foundation Classes product.
  10.  
  11. #include "stdafx.h"
  12. #include <malloc.h>
  13.  
  14. #ifdef AFX_INIT_SEG
  15. #pragma code_seg(AFX_INIT_SEG)
  16. #endif
  17.  
  18. #ifdef _DEBUG
  19. #undef THIS_FILE
  20. static char THIS_FILE[] = __FILE__;
  21. #endif
  22.  
  23. #undef AfxEnableWin30Compatibility
  24. #undef AfxEnableWin40Compatibility
  25. #undef AfxEnableWin31Compatibility
  26.  
  27. /////////////////////////////////////////////////////////////////////////////
  28. // Cached system metrics, etc
  29.  
  30. AFX_DATADEF AUX_DATA afxData;
  31.  
  32. // Win40 compatibility is now the default.  It is not necessary to call
  33. // this if your application is marked as 4.0.  It is provided only for
  34. // backward compatibility.
  35. void AFXAPI AfxEnableWin40Compatibility()
  36. {
  37.     if (afxData.bWin4)
  38.     {
  39.         // Later versions of Windows report "correct" scrollbar metrics
  40.         // MFC assumes the old metrics, so they need to be adjusted.
  41.         afxData.cxVScroll = WCE_FCTN(GetSystemMetrics)(SM_CXVSCROLL) + CX_BORDER;
  42.         afxData.cyHScroll = WCE_FCTN(GetSystemMetrics)(SM_CYHSCROLL) + CY_BORDER;
  43.         afxData.bMarked4 = TRUE;
  44.     }
  45. }
  46.  
  47. // Call this API in your InitInstance if your application is marked
  48. // as a Windows 3.1 application.
  49. // This is done by linking with /subsystem:windows,3.1.
  50. void AFXAPI AfxEnableWin31Compatibility()
  51. {
  52.     afxData.cxVScroll = WCE_FCTN(GetSystemMetrics)(SM_CXVSCROLL);
  53.     afxData.cyHScroll = WCE_FCTN(GetSystemMetrics)(SM_CYHSCROLL);
  54.     afxData.bMarked4 = FALSE;
  55. }
  56.  
  57. // Initialization code
  58. AUX_DATA::AUX_DATA()
  59. {
  60.     // Cache various target platform version information
  61.     DWORD dwVersion = ::WCE_FCTN(GetVersion)();
  62.     nWinVer = (LOBYTE(dwVersion) << 8) + HIBYTE(dwVersion);
  63.     bWin95 = (dwVersion & 0x80000000) != 0;
  64.     bWin4 = (BYTE)dwVersion >= 4;
  65.     bNotWin4 = 1 - bWin4;   // for convenience
  66.     bSmCaption = bWin4;
  67.     bMarked4 = FALSE;
  68.  
  69. #if !defined(_WIN32_WCE)
  70.     // determine various metrics based on EXE subsystem version mark
  71.     if (bWin4)
  72.         bMarked4 = (GetProcessVersion(0) >= 0x00040000);
  73. #endif // _WIN32_WCE
  74.  
  75.     // Cached system metrics (updated in CWnd::OnWinIniChange)
  76.     UpdateSysMetrics();
  77.  
  78.     // Cached system values (updated in CWnd::OnSysColorChange)
  79.     hbrBtnFace = NULL;
  80.     UpdateSysColors();
  81.  
  82.     // Standard cursors
  83.     hcurWait = ::WCE_FCTN(LoadCursor)(NULL, IDC_WAIT);
  84.     hcurArrow = ::WCE_FCTN(LoadCursor)(NULL, IDC_ARROW);
  85.     ASSERT(hcurWait != NULL);
  86.     ASSERT(hcurArrow != NULL);
  87.     hcurHelp = NULL;    // loaded on demand
  88.  
  89.     // cxBorder2 and cyBorder are 2x borders for Win4
  90.     cxBorder2 = bWin4 ? CX_BORDER*2 : CX_BORDER;
  91.     cyBorder2 = bWin4 ? CY_BORDER*2 : CY_BORDER;
  92.  
  93.     // allocated on demand
  94.     hbmMenuDot = NULL;
  95.     hcurHelp = NULL;
  96. }
  97.  
  98. #ifdef AFX_TERM_SEG
  99. #pragma code_seg(AFX_TERM_SEG)
  100. #endif
  101.  
  102. // Termination code
  103. AUX_DATA::~AUX_DATA()
  104. {
  105.     // clean up objects we don't actually create
  106.     AfxDeleteObject((HGDIOBJ*)&hbmMenuDot);
  107. }
  108.  
  109. #ifdef AFX_CORE1_SEG
  110. #pragma code_seg(AFX_CORE1_SEG)
  111. #endif
  112.  
  113. void AUX_DATA::UpdateSysColors()
  114. {
  115.     clrBtnFace = ::GetSysColor(COLOR_BTNFACE);
  116.     clrBtnShadow = ::GetSysColor(COLOR_BTNSHADOW);
  117.     clrBtnHilite = ::GetSysColor(COLOR_BTNHIGHLIGHT);
  118.     clrBtnText = ::GetSysColor(COLOR_BTNTEXT);
  119.     clrWindowFrame = ::GetSysColor(COLOR_WINDOWFRAME);
  120.  
  121.     hbrBtnFace = ::GetSysColorBrush(COLOR_BTNFACE);
  122.     ASSERT(hbrBtnFace != NULL);
  123.     hbrWindowFrame = ::GetSysColorBrush(COLOR_WINDOWFRAME);
  124.     ASSERT(hbrWindowFrame != NULL);
  125. }
  126.  
  127. void AUX_DATA::UpdateSysMetrics()
  128. {
  129.     // System metrics
  130.     cxIcon = WCE_FCTN(GetSystemMetrics)(SM_CXICON);
  131.     cyIcon = WCE_FCTN(GetSystemMetrics)(SM_CYICON);
  132.  
  133.     // System metrics which depend on subsystem version
  134.     if (bMarked4)
  135.         AfxEnableWin40Compatibility();
  136.     else
  137.         AfxEnableWin31Compatibility();
  138.  
  139.     // Device metrics for screen
  140.     HDC hDCScreen = GetDC(NULL);
  141.     ASSERT(hDCScreen != NULL);
  142.     cxPixelsPerInch = GetDeviceCaps(hDCScreen, LOGPIXELSX);
  143.     cyPixelsPerInch = GetDeviceCaps(hDCScreen, LOGPIXELSY);
  144.     ReleaseDC(NULL, hDCScreen);
  145. }
  146.  
  147. /////////////////////////////////////////////////////////////////////////////
  148.